﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text;

namespace _7.StringsCoderAndDecoder
{
    class StringCoderDecoder
    {
        public static byte[] GetBytes(string str, Encoding encoding)
        {
            byte[] stringBytes = encoding.GetBytes(str);
            
            return stringBytes;
        }

        public static string GetString(byte[] bytes, Encoding encoding)
        {
            string result = encoding.GetString(bytes);

            return result;
        }

        public static void PrintBytesSequences(byte[] bytes)
        {
            Console.WriteLine(BitConverter.ToString(bytes));
        }

        static void Main(string[] args)
        {
            Console.Write("Input a string:");
            string input = Console.ReadLine();

            byte[] utf8Bytes = GetBytes(input,Encoding.UTF8);
            PrintBytesSequences(utf8Bytes);
            string Utf8String = GetString(utf8Bytes,Encoding.UTF8);
            Console.WriteLine(Utf8String);

            byte[] asciiBytes = GetBytes(input, Encoding.ASCII);
            PrintBytesSequences(asciiBytes);
            string aciiString = GetString(asciiBytes, Encoding.ASCII);
            Console.WriteLine(aciiString);

            byte[] windows1251Bytes = GetBytes(input, Encoding.GetEncoding("windows-1251"));
            PrintBytesSequences(windows1251Bytes);
            string windows1251String = GetString(windows1251Bytes, Encoding.GetEncoding("windows-1251"));
            Console.WriteLine(windows1251String);

            byte[] utf16Bytes = GetBytes(input, Encoding.UTF32);
            PrintBytesSequences(utf16Bytes);
            string utf16String = GetString(utf16Bytes, Encoding.UTF32);
            Console.WriteLine(utf16String);

            byte[] unicodeBytes = GetBytes(input, Encoding.Unicode);
            PrintBytesSequences(unicodeBytes);
            string unicodeString = GetString(unicodeBytes, Encoding.Unicode);
            Console.WriteLine(unicodeString);

        }
    }
}
